package com.gao.test;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gao.pojo.User;
import com.gao.service.ClassService;
import com.gao.service.UserService;
import com.gao.vo.Class_users;
import com.gao.vo.UserClas;
import com.github.pagehelper.PageInfo;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.List;

@RunWith (SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:applicationContext.xml")
public class Usertest {
    @Autowired
    private UserService userServiceImpl;
    @Autowired
    private ClassService classServiceImpl;
    @Test
   public void SelAll(){
        List<User> list = userServiceImpl.list ();
        for (User user : list) {
            System.out.println ( "user = " + user );
        }
    }


    @Test
    public void class_userslist(){
        List<Class_users> users = classServiceImpl.selClassList ();
        for (Class_users class_users : users) {
            System.out.println (class_users);
        }
    }

    @Test
    public void userpage(){
        PageInfo<UserClas> info = userServiceImpl.selUserClasPage ( 0, 3 );
        List<UserClas> list = info.getList ();
        for (UserClas clas : list) {
            System.out.println ( "clas = " + clas );
        }
    }
    @Test
    public void test1(){
        QueryWrapper<User> wrapper = new QueryWrapper<> ();
        wrapper.like ( "user_name","z" );
        Page<User> page = userServiceImpl.page ( new Page<User> ( 2,3 ));
        List<User> list = page.getRecords ();
        for (User user : list) {
            System.out.println ( "user = " + user );
        }
        System.out.println (page.getCurrent ());
        System.out.println (page.getSize ());
        System.out.println (page.getTotal ());
        System.out.println (page.getPages ());
    }
    @Test
    public void test2(){
        List<User> list = userServiceImpl.selUsers ("高大人");
    }


}
